#include "ma_appcreat.h"
#include "FreeRTOS.h"
#include "ma_uart_rxhandle.h"
#include "ma_uart_tx.h"
#include "queue.h"
#include "task.h"

QueueHandle_t pRxBuffQueue_Handle = NULL; // 用于存放rx_buff指针

TaskHandle_t AppCreateTask_Handle = NULL; // 用于任务创建

void AppCreateTask(void)
{
    taskENTER_CRITICAL(); // 进入临界区

    pRxBuffQueue_Handle = xQueueCreate(1, sizeof(UART_RxBuff_Type *));

    xTaskCreate(
        (TaskFunction_t)UART_RxHandleTask,
        (const char *)"UART_RxHandleTask",
        (uint16_t)UART_RxHandleTask_STACK_SIZE,
        (void *)NULL,
        (UBaseType_t)UART_RxHandleTask_PRIO,
        (TaskHandle_t *)&UART_RxHandleTask_Handle);

    xTaskCreate(
        (TaskFunction_t)UART_TxTask,
        (const char *)"UART_TxTask",
        (uint16_t)UART_TxTask_STACK_SIZE,
        (void *)NULL,
        (UBaseType_t)UART_TxTask_PRIO,
        (TaskHandle_t *)&UART_TxTask_Handle);

    vTaskDelete(AppCreateTask_Handle); // 使命完成，删除

    taskEXIT_CRITICAL(); // 退出临界区
}
